<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

/**
 * After Login
 */
Route::group(array('before' => 'auth'), function(){
    /**
     * CSRF Protection
     *
     * Remember to add Form token inside the form
     */
    Route::group(array('before' => 'csrf'), function(){

    });

    Route::get('/dashboard', array(
        'as'   => 'dashboard',
        'uses' => 'HomeController@showDashboard'
    ));

    Route::get('/', function (){
        return Redirect::route('dashboard');
    });

    Route::get('/logout', array(
        'as'   => 'logout',
        'uses' => 'UserController@doLogout'
    ));

    /*
     * Routing untuk Master
     */

    Route::get('/provinsis/combo-view-kabupatens', array(
        'as'   => 'provinsis.combo.view.kabupatens',
        'uses' => 'ProvinsisController@getComboViewKabupatens'
    ));

    Route::get('/provinsis/data', array(
        'as'   => 'provinsis.data-table',
        'uses' => 'ProvinsisController@dataTable'
    ));


    Route::get('/kabupatens/combo-view-kecamatans', array(
        'as'   => 'kabupatens.combo.view.kecamatans',
        'uses' => 'KabupatensController@getComboViewKecamatans'
    ));

    Route::get('/kabupatens/data-provinsi', array(
        'as'   => 'kabupatens.data-provinsi',
        'uses' => 'KabupatensController@dataTable'
    ));

    Route::get('/kabupatens/data', array(
        'as'   => 'kabupatens.data-table',
        'uses' => 'KabupatensController@dataView'
    ));


    Route::get('/kecamatans/combo-view-kelurahans', array(
        'as'   => 'kecamatans.combo.view.kelurahans',
        'uses' => 'KecamatansController@getComboViewKelurahans'
    ));


    Route::get('/kecamatans/data', array(
        'as'   => 'kecamatans.data-table',
        'uses' => 'KecamatansController@dataTable'
    ));

    Route::get('/kecamatans/data-kabupaten', array(
        'as'   => 'kecamatans.data-kab',
        'uses' => 'KecamatansController@dataKabupaten'
    ));


    Route::get('/kelurahans/data', array(
        'as'   => 'kelurahans.data-table',
        'uses' => 'KelurahansController@dataTable'
    ));

    Route::get('/kelurahans/data-kecamatan', array(
        'as'   => 'kelurahans.data-kec',
        'uses' => 'KelurahansController@dataKecamatan'
    ));


    /********************
    * IF ROLE AS ADMIN *
    ********************/
    Route::group(array('before' => 'admin'), function() {

      Route::resource('users', 'UserController');
      Route::resource('agamas', 'AgamasController');
      Route::resource('penduduks', 'PenduduksController');
      Route::resource('tipes', 'TipesController');
      Route::resource('provinsis', 'ProvinsisController');
      Route::resource('kabupatens', 'KabupatensController');
      Route::resource('kecamatans', 'KecamatansController');
      Route::resource('kelurahans', 'KelurahansController');


      Route::resource('status_keluargas', 'StatusKeluargasController');

      Route::resource('pendidikans', 'PendidikansController');

      Route::resource('status_hunians', 'StatusPenghasilansController');

      Route::resource('jenis_pekerjaans', 'JenisPekerjaansController');

    });

    Route::resource('detail_kipems', 'DetailKipemsController');

    Route::resource('notifs', 'NotifsController');
    /**
     * Routing untuk Penduduk
     */
    Route::get('/penduduk', array(
        'as'   => 'penduduk',
        'uses' => 'PenduduksController@index'
    ));

    Route::get('/penduduk/check', array(
        'as'   => 'penduduks.check',
        'uses' => 'PenduduksController@check'
    ));

    Route::any('/penduduk/create', array(
        'as'   => 'penduduks.create',
        'uses' => 'PenduduksController@create'
    ));

    Route::any('/penduduk/filter', array(
        'as'   => 'penduduks.filter',
        'uses' => 'PenduduksController@filter'
    ));

    Route::post('/pendudukpenjamin/', array(
        'as'   => 'pendudukpenjamin',
        'uses' => 'LokasisController@pendudukpenjamin'
    ));

    Route::get('/penduduk/all', array(
        'as'   => 'penduduks.all',
        'uses' => 'PenduduksController@datatableAllPenduduks'
    ));

    Route::post('/penduduk/perkk', array(
        'as'   => 'penduduks.perkk',
        'uses' => 'PenduduksController@penduduksPerKK'
    ));

    /**
     * Batas Routing Penduduk
     */


    /**
     * Routing untuk Kipem
     */
    Route::resource('kipems', 'KipemsController');

    Route::post('/kabupatenkipem/', array(
        'as'   => 'kabupatenkipem',
        'uses' => 'KipemsController@kabupatenkipem'
    ));

    Route::post('/kecamatankipem/', array(
        'as'   => 'kecamatankipem',
        'uses' => 'KipemsController@kecamatankipem'
    ));

    Route::post('/kelurahankipem/', array(
        'as'   => 'kelurahankipem',
        'uses' => 'KipemsController@kelurahankipem'
    ));

    Route::post('/lokasipendamping/', array(
        'as'   => 'lokasipendamping',
        'uses' => 'KipemsController@lokasipendamping'
    ));

    Route::any('/lokasipendampingmodal/', array(
        'as'   => 'lokasipendampingmodal',
        'uses' => 'KipemsController@lokasipendampingmodal'
    ));

    Route::post('/lamakipem/', array(
        'as'   => 'lamakipem',
        'uses' => 'KipemsController@lamakipem'
    ));

    Route::post('/lamakipemterdaftar/', array(
        'as'   => 'lamakipemterdaftar',
        'uses' => 'KipemsController@lamakipemterdaftar'
    ));

    Route::get('/kipem/check', array(
        'as'   => 'kipems.check',
        'uses' => 'KipemsController@check'
    ));

    Route::any('/kipem/create', array(
        'as'   => 'kipems.create',
        'uses' => 'KipemsController@create'
    ));

    Route::get('/kipem/notif', array(
        'as'   => 'kipems.notif',
        'uses' => 'KipemsController@indexKipems'
    ));

    Route::get('/kipem/notif/map', array(
       'as'   => 'kipems.notif.map',
        'uses' => 'KipemsController@notifMap' 
    ));

    Route::get('/kipem/check_perpanjangan', array(
        'as'   => 'kipems.checkperpanjangan',
        'uses' => 'KipemsController@checkperpanjangan'
    ));

    Route::get('/kipem/displayperpanjangan', array(
        'as'   => 'kipems.displayperpanjangan',
        'uses' => 'KipemsController@datatableAllPerpanjangan'
    ));

    Route::get('/kipem/perpanjangan/{ktp}', array(
        'as'   => 'kipems.perpanjangan',
        'uses' => 'KipemsController@perpanjangan'
    ));

    Route::any('/kipem/editperpanjangan/{id}', array(
        'as'   => 'kipems.editperpanjangan',
        'uses' => 'KipemsController@editperpanjangan'
    ));

    Route::get('/kipem/form/perpanjangan/{ktp}', array(
        'as'   => 'kipems.formperpanjangan',
        'uses' => 'KipemsController@formperpanjangan'
    ));

    Route::get('/kipem/inactive/{id}', array(
        'as'   => 'kipems.inactive',
        'uses' => 'KipemsController@inactive'
    ));

    Route::any('/kipem/filter', array(
        'as'   => 'kipems.filter',
        'uses' => 'KipemsController@filter'
    ));

    Route::any('/kipem/proses', array(
        'as'   => 'kipems.proses',
        'uses' => 'KipemsController@indexproses'
    ));

    Route::get('/kipem/proseskipem/{ktp}', array(
        'as'   => 'kipems.proseskipem',
        'uses' => 'KipemsController@proseskipem'
    ));

    Route::any('/kipem/editproses/{id}', array(
        'as'   => 'kipems.editproses',
        'uses' => 'KipemsController@editproses'
    ));

    Route::get('/kipem/displayall', array(
        'as'   => 'kipems.displayall',
        'uses' => 'KipemsController@datatableAllProses'
    ));

    Route::get('/kipem/all', array(
        'as'   => 'kipems.all',
        'uses' => 'KipemsController@datatableAllKipems'
    ));

    Route::get('/kipem/notif-get', array(
        'as'   => 'kipems.notif-get',
        'uses' => 'KipemsController@dataTableNotif'
    ));

    Route::get('/kipem/notif-count', array(
        'as'   => 'kipems.notif-count',
        'uses' => 'KipemsController@getNotif'
    ));

    /**
     * Routing Tamu
     */

    Route::resource('tamus', 'TamusController');

    Route::any('/tamu/create', array(
        'as'   => 'tamus.create',
        'uses' => 'TamusController@create'
    ));

    Route::any('/tamu/filter', array(
        'as'   => 'tamus.filter',
        'uses' => 'TamusController@filter'
    ));

    Route::get('/tamu/all', array(
        'as'   => 'tamus.all',
        'uses' => 'TamusController@datatableAllTamus'
    ));

    /*
     * Routing Lokasi
     */

    Route::get('/lokasis/gis', array(
        'as'   => 'lokasis.gis',
        'uses' => 'LokasisController@gis'
    ));
    Route::get('/lokasis/get-all-markers', array(
        'as'   => 'lokasis.get.all.markers',
        'uses' => 'LokasisController@getAllMarkers'
    ));
    Route::get('/lokasis/get-marker-infowindow', array(
        'as'   => 'lokasis.get.marker.infowindow',
        'uses' => 'LokasisController@getMarkerInfowindow'
    ));
    Route::resource('lokasis', 'LokasisController');
    Route::get('/lokasis', array(
        'as'   => 'lokasis',
        'uses' => 'LokasisController@index'
    ));
    Route::get('/datatable/lokasis', array(
        'as'   => 'lokasis.datatable',
        'uses' => 'LokasisController@datatableIndex'
    ));
    Route::get('/lokasis/{id}/penduduk', array(
       'as'   => 'lokasis.penduduk',
        'uses' => 'LokasisController@penduduk'
    ));
    Route::get('/lokasis/{id}/all-penduduks', array(
        'as'   => 'lokasis.all.penduduks',
        'uses' => 'LokasisController@datatableAllPenduduks'
    ));
    Route::get('/lokasis/{id}/available-penduduks', array(
        'as'   => 'lokasis.available.penduduks',
        'uses' => 'LokasisController@datatableAvailablePenduduks'
    ));
    Route::get('/lokasis/{id}/partials-all-penduduks', array(
        'as'   => 'lokasis.partials.all.penduduks',
        'uses' => 'LokasisController@partialsAllPenduduks'
    ));
    Route::post('/lokasis/{id}/mapping-penduduks', array(
        'as'   => 'lokasis.mapping.penduduks',
        'uses' => 'LokasisController@mappingPenduduks'
    ));
    Route::post('/lokasis/{id}/unmapping-penduduk', array(
        'as'   => 'lokasis.unmapping.penduduk',
        'uses' => 'LokasisController@unmappingPenduduk'
    ));

    /*
     * Batas routing Master
     */

    /*
     * Routing untuk Pengaturan
     */
    Route::get('/pengaturan/lingkungan', array(
        'as'   => 'lingkungan',
        'uses' => 'LingkunganController@index'
    ));
    Route::post('/pengaturan/lingkungan-update', array(
        'as'   => 'lingkungan.update',
        'uses' => 'LingkunganController@update'
    ));
    Route::post('/pengaturan/lingkungan/upload-logo', array(
        'as'   => 'lingkungan.upload.logo',
        'uses' => 'LingkunganController@uploadLogo'
    ));
    Route::post('/pengaturan/lingkungan/upload-ttd-kepling', array(
        'as'   => 'lingkungan.upload.ttd.kepling',
        'uses' => 'LingkunganController@uploadTTDKepling'
    ));
    Route::post('/pengaturan/lingkungan/upload-ttd-keldat', array(
        'as'   => 'lingkungan.upload.ttd.keldat',
        'uses' => 'LingkunganController@uploadTTDKeldat'
    ));
    Route::get('/pengaturan/lingkungan/get-polygon-json', array(
        'as'   => 'lingkungan.get.polygon.json',
        'uses' => 'LingkunganController@getPolygonJSON'
    ));
    /*
     * Batas Pengaturan
     */

    /**
     * Routing untuk STLD (Susu Telor Lawar Daluman)
     */
    Route::resource('stlds', 'StldsController');

    Route::any('/stld/filter', array(
        'as'   => 'stlds.filter',
        'uses' => 'StldsController@filter'
    ));

    Route::get('/stld/all', array(
        'as'   => 'stlds.all',
        'uses' => 'StldsController@datatableAllStlds'
    ));
    /*
     * Batas STLD
     */

    /**
     * Routing untuk Laporan
     */
    Route::get('/laporan/penduduk', array(
        'as'   => 'laporan.penduduk',
        'uses' => 'LaporansController@laporanpenduduk'
    ));
    Route::get('/laporan/pendudukall', array(
        'as'   => 'laporan.pendudukall',
        'uses' => 'LaporansController@datatableLaporanPenduduks'
    ));
    Route::get('/laporan/kipem', array(
        'as'   => 'laporan.kipem',
        'uses' => 'LaporansController@laporankipem'
    ));
    Route::get('/laporan/kipemall', array(
        'as'   => 'laporan.kipemall',
        'uses' => 'LaporansController@datatableLaporanKipems'
    ));
    /*
     * Batas Laporan
     */

});

// Show login form
Route::get('/', array(
    'as'   => 'login',
    'uses' => 'HomeController@showLogin'
));

/**
 * Before Login
 */
Route::group(array('before' => 'guest'), function(){
    // Login post
    Route::post('/login', array(
        'as'   => 'do-login',
        'uses' => 'UserController@doLogin'
    ));
});
